package org.unideb.beerfactory.dao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.unideb.beerfactory.dto.OrderDTO;
import org.unideb.beerfactory.entity.Order;

@Repository
public interface OrderDao extends PagingAndSortingRepository<Order, Long>,
	BaseConvertDao<Order, OrderDTO>{
	
	Page<Order> findByStatusStartsWith(String status, Pageable pageable);
	Page<Order> findByNameStartsWith(String name, Pageable pageable);
	
	@Query(value = "SELECT count(*) FROM ORDERS", nativeQuery = true)
	int countById();
	
	List<Order> findByStatus(String status);
	List<Order> findByPartnerId(Long partnerId);
	
	Integer countByStatus(String status);
}
